    //首页header
    var header = {
        menuData: {},//菜单数据
    };


    /***
     *  构建二级菜单
     *  */
    header.initSecondMenu = function (menuData) {
        var mainNav = $('.main-nav');//二级菜单

        //mainNav.addClass("main-nav-show");
        //var mainMask = $('#mask-div');//遮罩层
        if (menuData != undefined && (menuData.authCode == 'brand' || menuData.authCode == 'auth')) {
            var navDiv = '<div class="nav-content ">';
            navDiv += '<div class="nav-banner nav20"><a href="'+menuData.link+'"><img src="' + menuData.bannerUrl + '" alt="" class="imgItem"/></a>';
            navDiv += '<span class="nav-banner-title">' + menuData.bannerTitle + '</span></div>';
            navDiv += '<div class="second-nav nav70"><ul>';
            if (menuData.childMenu.length > 0) {
                $.each(menuData.childMenu, function (index, obj) {
                    navDiv += '<li class="second-tag"><a href="' + obj.link + '">' + obj.name + '</a></li>';
                });
            }
            navDiv += '</ul></div></div>';

            mainNav.empty().append(navDiv);
        }
        //产品列表展示不一样
        if (menuData != undefined && menuData.authCode == 'pro') {
            var navDiv = '<div class="nav-content ">';
            navDiv += '<div class="second-nav nav20" style="    margin-bottom: 48px;">';
            // if( index == 1 ){
                navDiv += '<div class="nav-banner" style="position: relative;\n' +
                    'margin-top: 0;"><a href="'+menuData.link+'"><img src="' + menuData.bannerUrl + '" alt=""/></a>';
                navDiv += '<span class="nav-banner-title">' + menuData.bannerTitle + '</span></div>';
            // }
            if (menuData.childMenu.length > 0) {
                $.each(menuData.childMenu, function (index, obj) {
                    navDiv += '<div class="second-tag">';
                    navDiv += '<h3 class="tag-title">' + obj.name + '</h3><ul>';
                    $.each(obj.childMenu, function (i, tag) {
                        navDiv += '<li><a href="/web/productExhibition?tagId=' + tag.id + '">' + tag.name + '</a></li>';
                    });
                    navDiv += '</ul></div>';

                });
            }
            navDiv += '</div></div>';

            mainNav.empty().append(navDiv);
        }
        //资讯合作菜单在前
        if( menuData != undefined && (menuData.authCode == 'infor' || menuData.authCode == 'hz')){
            var navDiv = '<div class="nav-content ">';

            navDiv += '<div class="second-nav nav20"><ul>';
            if (menuData.childMenu.length > 0) {
                $.each(menuData.childMenu, function (index, obj) {
                    navDiv += '<li class="second-tag"><a href="' + obj.link + '">' + obj.name + '</a></li>';
                });
            }
            navDiv += '</ul></div>';
            navDiv += '<div class="nav-banner"><a href="'+menuData.link+'"><img src="' + menuData.bannerUrl + '" alt="" class="imgItem"/></a>';
            navDiv += '<span class="nav-banner-title">' + menuData.bannerTitle + '</span></div></div>';

            mainNav.empty().append(navDiv);
        }
        $("#menu").mouseleave(header.hideSecondDiv);
    }
    /**
     * 隐藏当前菜单
     */
    header.hideSecondDiv = function () {
        //debugger;
        $('.main-nav').fadeOut(1000);
        //添加遮罩层
        $("#mask-div").css({"display":"none"});
    }

    header.selLiCss = function (authCode) {
        if (authCode != undefined) {
            $('.main-menu li a[name=' + authCode + ']').addClass("main-menu-btn-af");
            $('.main-menu li a[name!=' + authCode + ']').removeClass("main-menu-btn-af");
        } else {
            $('.main-menu li a').removeClass("main-menu-btn-af");
        }
    }
    /**
     * 初始化构建首页导航菜单
     */
    header.initMenu = function () {
        //获取菜单div
        var $menu = $(".main-menu");
        $.ajax({
            async: false,
            url: '/web/findIndexMenu',
            success: function (result) {
                if (result && result.code == 200) {
                    var data = result.data;
                    //循环获取菜单列表
                    var itemMenuDiv = '';
                    $.each(data, function (index, obj) {
                        if (index == 0) {
                            itemMenuDiv += '<li><a class="main-menu-btn main-menu-btn-af" href="' + obj.link + '" name="' + obj.authCode + '"><span>' + obj.name + '</span></a></li>';
                        } else {
                            itemMenuDiv += '<li><a class="main-menu-btn" name="' + obj.authCode + '"><span>' + obj.name + '</span></a></li>';
                        }
                        header.menuData[obj.authCode] = obj;

                    })
                    $menu.empty().append(itemMenuDiv);
                    $menu.find('li').on('mouseover', function () {//构建二级菜单
                        var authCode = $(this).find("a").attr("name");
                        //一级菜单添加选中样式
                        $menu.find('li a').removeClass("main-menu-btn-af");
                        $(this).find("a").addClass("main-menu-btn-af");
                        if (authCode != undefined && authCode != '') {
                            if( authCode =='index'){
                                header.hideSecondDiv();
                            }else{
                                $('.main-nav').fadeIn(1000);
                                header.initSecondMenu(header.menuData[authCode]);
                            }
                        }
                        //添加遮罩层
                        //$("#mask-div").css({"display":"block"});
                    });
                }
            },
            error: function () {
                layer.alert('服务器出错啦！', {icon: 2, title: '错误'});
            }
        });
    };


    $('.search-btn').on('click', function () {
        $('#searchProduct').addClass("search-module-af");
    });

    $("#searchProduct").mouseleave(function () {
        $('#searchProduct').removeClass("search-module-af");
    });

    //初始化
    header.initMenu();

    /*window.onscroll = function(){

        //可视范围内高度
        var clientHeight=0;
        if(document.body.clientHeight&&document.documentElement.clientHeight){
            var clientHeight=(document.body.clientHeight<document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
        }else{
            var clientHeight=(document.body.clientHeight>document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
        }
        //整体高度
        var contentHeight = Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
        var scrollTop=0;
        if(document.documentElement&&document.documentElement.scrollTop){
            scrollTop=document.documentElement.scrollTop;
        }else if(document.body){
            scrollTop=document.body.scrollTop;
        }
        // 滚动条距离底部的高度
        var bheight=contentHeight-clientHeight-scrollTop;
        if( (contentHeight - clientHeight) > 320 ){
            if( scrollTop >= 106){
                /!*$("#header").css({
                    "position":"fixed",
                    "width":"92%"
                });*!/
                $("#menu").addClass("is-hidden");
                $("#header").addClass("fiexd-header");
            }else{
                /!*$("#header").css({
                    "position":"relative",
                    "width":"100%"
                });*!/
                $("#menu").removeClass("is-hidden");
                $("#header").removeClass("fiexd-header");
            }
        }
    };*/
